Skip to content

Only allow specific trailers#199

Open
jeremyevans wants to merge 1 commit intoruby:masterfrom
jeremyevans:chunked-trailers
Open

Only allow specific trailers#199
jeremyevans wants to merge 1 commit intoruby:masterfrom
jeremyevans:chunked-trailers

Conversation

@jeremyevans
Copy link
Copy Markdown
Contributor

Only allow trailers listed in the Trailer header. Even if listed there, disallow the following names, based on Mozilla recommendations:

content-encoding content-type content-range trailer authorization
set-cookie transfer-encoding content-length host cache-control
max-forwards te

There are probably additional ones we should disallow, but this is a decent start.

Do not merge the header and trailer data. Parse the trailers into a separate hash, and for allowed names, copy the value into the headers hash.

This ignores invalid trailers instead of raising an exception, which is preferable for backwards compatibility.

In order to get the new test to pass, make content_length return nil instead of of raising a TypeError if no content length was provided. Also, parse the content length as decimal instead of trying to autodetect the radix.

Fixes #198

Only allow trailers listed in the `Trailer` header. Even if listed
there, disallow the following names, based on Mozilla
recommendations:

```
content-encoding content-type content-range trailer authorization
set-cookie transfer-encoding content-length host cache-control
max-forwards te
```

There are probably additional ones we should disallow, but this
is a decent start.

Do not merge the header and trailer data. Parse the trailers into
a separate hash, and for allowed names, copy the value into the
headers hash.

This ignores invalid trailers instead of raising an exception,
which is preferable for backwards compatibility.

In order to get the new test to pass, make content_length return
nil instead of of raising a TypeError if no content length was
provided. Also, parse the content length as decimal instead of
trying to autodetect the radix.

Fixes ruby#198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] WEBrick reparses trailer Content-Length into canonical request state, enabling request metadata confusion / request smuggling

1 participant